/* Copyright (C) 2010 Moritz Bitsch
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 *      Moritz Bitsch <moritzbitsch@googlemail.com>
 */

namespace Webappi {
	public class Result : Object {
		public unowned SList<string> header { get; set; }
		public string contentType { get; set; default = "text/html; charset=utf-8"; }
		public char[] result { get; set; default = "<html><body>Hallo, Welt!</body></html>".to_utf8(); }
		public int status { get; set; default = 200; }

		public Result() {
			header = new SList<string>();
		}

		public void add_header (string key, string val, bool escape=true) {
			if (escape) {
				header.append("%s: %s".printf(Uri.escape_string(key, "", true), Uri.escape_string(val, "", true)));
			} else {
				header.append("%s: %s".printf(key, val));
			}
		}
	}
}
